import { defineStore } from 'pinia'
import { useLogicStore } from './logic'
export const useUserStore = defineStore('user', {
    // 状态
    state: () => {
        return {
            username: '张三',
            password: '123456'
        }
    },
    // 方法
    actions: {
        updateName(username) {
            this.username = username
            this.setData('互相调用')
        },
        setData(data) {
            console.log(data)
            // 调用其他库的方法和状态
            console.log(useLogicStore().name);
        },
        // 异步
        async login() {
            await setTimeout(() => { }, 3000)
        }
    },
    // 类似计算属性
    getters: {
        fullName: (state) => {
            return state.username + '丰'
        }
    }
})